---
# tasks file for nginx

  - name: nginx
    apt:
      name: nginx
      state: latest
    when: ansible_os_family == "Debian"  
  
  - name:  Generate index.html
    template:
      src: index.html.j2
      dest: "{{ destin_file }}/index.html"
      mode: 0755
    notify: Restarted nginx


 # - name: Copy index.html
   # copy: 
    # src: "{{ sours_file }}"
     #dest: "{{ destin_file }}"
     #mode: 0555
    #notify: Restarted nginx

  - name: start nginx
    service:
      name: nginx
      state: started
      enabled: yes
  
  - name: "wait_for port {{ ports }} to become open on the host, don't start checking for 5 seconds"
    wait_for:
      port: "{{ ports }}"
      delay: 5

      
  - name: "Show current ip"
    tags: 
     - debug
    debug:
      msg: ["http://{{ ansible_facts.all_ipv4_addresses[0] }}:{{ ports }}", "OS:{{ ansible_facts.os_family }}"]

 